Validating input using java.util.Scanner [closed]

Posted by bhavna raghuvanshi on Stack Overflow See other posts from Stack Overflow or by bhavna raghuvanshi
Published on 2010-06-17T06:20:58Z Indexed on 2010/06/17 9:23 UTC
Read the original article Hit count: 180

Filed under:
|
|

I'm taking user input from System.in using a java.util.Scanner. I need to validate the input for things like:

  • It must be a non-negative number
  • It must be an alphabetical letter
  • ...etc

What's the best way to do this?

© Stack Overflow or respective owner

Related posts about java

Related posts about input-validation